package Java攻略._2_java_util_function包._3_Predicate接口;

import java.util.Arrays;
import java.util.stream.Collectors;

public class _8_查找以给定字符串开头的字符串 {

    public static void main(String[] args) {

        _8_查找以给定字符串开头的字符串 _8 = new _8_查找以给定字符串开头的字符串();
        String nameStartingWith = _8.getNameStartingWith("jianke",
                "jianke xuliang"
                , "xiake zhanxingfei"
                , "jianke baiyunrui"
                , "xiake liushijie"
        );

        System.out.println(nameStartingWith);
    }

    public String getNameStartingWith(String s, String... names){

       return Arrays.stream(names)
                .filter(x -> x.startsWith(s))
                .collect(Collectors.joining(", "));
    }
}
